home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / lisp / wgdb-42.lha / wgdb-4.2 / gdb / nindy-share / b.out.h next >
C/C++ Source or Header  |  1992-09-11  |  6KB  |  159 lines

  1. /* Id: b.out.h,v 1.1.1.1 1991/03/28 16:20:47 rich Exp $
  2.  *
  3.  * This file is a modified version of 'a.out.h'.  It is to be used in all
  4.  * all GNU tools modified to support the i80960 (or tools that operate on
  5.  * object files created by such tools).
  6.  *
  7.  * All i80960 development is done in a CROSS-DEVELOPMENT environment.  I.e.,
  8.  * object code is generated on, and executed under the direction of a symbolic
  9.  * debugger running on, a host system.  We do not want to be subject to the
  10.  * vagaries of which host it is or whether it supports COFF or a.out format,
  11.  * or anything else.  We DO want to:
  12.  *
  13.  *    o always generate the same format object files, regardless of host.
  14.  *
  15.  *    o have an 'a.out' header that we can modify for our own purposes
  16.  *      (the 80960 is typically an embedded processor and may require
  17.  *      enhanced linker support that the normal a.out.h header can't
  18.  *      accommodate).
  19.  *
  20.  * As for byte-ordering, the following rules apply:
  21.  *
  22.  *    o Text and data that is actually downloaded to the target is always
  23.  *      in i80960 (little-endian) order.
  24.  *
  25.  *    o All other numbers (in the header, symbols, relocation directives)
  26.  *      are in host byte-order:  object files CANNOT be lifted from a
  27.  *      little-end host and used on a big-endian (or vice versa) without
  28.  *      modification.
  29.  *
  30.  *    o The downloader ('comm960') takes care to generate a pseudo-header
  31.  *      with correct (i80960) byte-ordering before shipping text and data
  32.  *      off to the NINDY monitor in the target systems.  Symbols and
  33.  *      relocation info are never sent to the target.
  34.  */
  35.  
  36.  
  37. #define BMAGIC    0415
  38. /* We don't accept the following (see N_BADMAG macro).
  39.  * They're just here so GNU code will compile.
  40.  */
  41. #define    OMAGIC    0407        /* old impure format */
  42. #define    NMAGIC    0410        /* read-only text */
  43. #define    ZMAGIC    0413        /* demand load format */
  44.  
  45. /* FILE HEADER
  46.  *    All 'lengths' are given as a number of bytes.
  47.  *    All 'alignments' are for relinkable files only;  an alignment of
  48.  *        'n' indicates the corresponding segment must begin at an
  49.  *        address that is a multiple of (2**n).
  50.  */
  51. struct exec {
  52.     /* Standard stuff */
  53.     unsigned long a_magic;    /* Identifies this as a b.out file    */
  54.     unsigned long a_text;    /* Length of text            */
  55.     unsigned long a_data;    /* Length of data            */
  56.     unsigned long a_bss;    /* Length of runtime uninitialized data area */
  57.     unsigned long a_syms;    /* Length of symbol table        */
  58.     unsigned long a_entry;    /* Runtime start address        */
  59.     unsigned long a_trsize;    /* Length of text relocation info    */
  60.     unsigned long a_drsize;    /* Length of data relocation info    */
  61.  
  62.     /* Added for i960 */
  63.     unsigned long a_tload;    /* Text runtime load address        */
  64.     unsigned long a_dload;    /* Data runtime load address        */
  65.     unsigned char a_talign;    /* Alignment of text segment        */
  66.     unsigned char a_dalign;    /* Alignment of data segment        */
  67.     unsigned char a_balign;    /* Alignment of bss segment        */
  68.     unsigned char unused;    /* (Just to make struct size a multiple of 4) */
  69. };
  70.  
  71. #define N_BADMAG(x)    (((x).a_magic)!=BMAGIC)
  72. #define N_TXTOFF(x)    ( sizeof(struct exec) )
  73. #define N_DATOFF(x)    ( N_TXTOFF(x) + (x).a_text )
  74. #define N_TROFF(x)    ( N_DATOFF(x) + (x).a_data )
  75. #define N_DROFF(x)    ( N_TROFF(x) + (x).a_trsize )
  76. #define N_SYMOFF(x)    ( N_DROFF(x) + (x).a_drsize )
  77. #define N_STROFF(x)    ( N_SYMOFF(x) + (x).a_syms )
  78.  
  79. /* A single entry in the symbol table
  80.  */
  81. struct nlist {
  82.     union {
  83.         char    *n_name;
  84.         struct nlist *n_next;
  85.         long    n_strx;        /* Index into string table    */
  86.     } n_un;
  87.     unsigned char n_type;    /* See below                */
  88.     char    n_other;    /* Used in i80960 support -- see below    */
  89.     short    n_desc;
  90.     unsigned long n_value;
  91. };
  92.  
  93.  
  94. /* Legal values of n_type
  95.  */
  96. #define N_UNDF    0    /* Undefined symbol    */
  97. #define N_ABS    2    /* Absolute symbol    */
  98. #define N_TEXT    4    /* Text symbol        */
  99. #define N_DATA    6    /* Data symbol        */
  100. #define N_BSS    8    /* BSS symbol        */
  101. #define N_FN    31    /* Filename symbol    */
  102.  
  103. #define N_EXT    1    /* External symbol (OR'd in with one of above)    */
  104. #define N_TYPE    036    /* Mask for all the type bits            */
  105. #define N_STAB    0340    /* Mask for all bits used for SDB entries     */
  106.  
  107. /* MEANING OF 'n_other'
  108.  *
  109.  * If non-zero, the 'n_other' fields indicates either a leaf procedure or
  110.  * a system procedure, as follows:
  111.  *
  112.  *    1 <= n_other <= 32 :
  113.  *        The symbol is the entry point to a system procedure.
  114.  *        'n_value' is the address of the entry, as for any other
  115.  *        procedure.  The system procedure number (which can be used in
  116.  *        a 'calls' instruction) is (n_other-1).  These entries come from
  117.  *        '.sysproc' directives.
  118.  *
  119.  *    n_other == N_CALLNAME
  120.  *        the symbol is the 'call' entry point to a leaf procedure.
  121.  *        The *next* symbol in the symbol table must be the corresponding
  122.  *        'bal' entry point to the procedure (see following).  These
  123.  *        entries come from '.leafproc' directives in which two different
  124.  *        symbols are specified (the first one is represented here).
  125.  *    
  126.  *
  127.  *    n_other == N_BALNAME
  128.  *        the symbol is the 'bal' entry point to a leaf procedure.
  129.  *        These entries result from '.leafproc' directives in which only
  130.  *        one symbol is specified, or in which the same symbol is
  131.  *        specified twice.
  132.  *
  133.  * Note that an N_CALLNAME entry *must* have a corresponding N_BALNAME entry,
  134.  * but not every N_BALNAME entry must have an N_CALLNAME entry.
  135.  */
  136. #define    N_CALLNAME    -1
  137. #define    N_BALNAME    -2
  138.  
  139.  
  140. struct relocation_info {
  141.     int     r_address;    /* File address of item to be relocated    */
  142.     unsigned
  143.         r_symbolnum:24,/* Index of symbol on which relocation is based*/
  144.         r_pcrel:1,    /* 1 => relocate PC-relative; else absolute
  145.                  *    On i960, pc-relative implies 24-bit
  146.                  *    address, absolute implies 32-bit.
  147.                  */
  148.         r_length:2,    /* Number of bytes to relocate:
  149.                  *    0 => 1 byte
  150.                  *    1 => 2 bytes
  151.                  *    2 => 4 bytes -- only value used for i960
  152.                  */
  153.         r_extern:1,
  154.         r_bsr:1,    /* Something for the GNU NS32K assembler */
  155.         r_disp:1,    /* Something for the GNU NS32K assembler */
  156.         r_callj:1,    /* 1 if relocation target is an i960 'callj' */
  157.         nuthin:1;    /* Unused                */
  158. };
  159.